<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html>
<html lang="en">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<head>
<%@ include file="/common/common-css.jsp"%>
<style>
#jquery-table td {
	cursor: pointer !important
}

.load_bg {
	background: #000;
	opacity: 0.1;
	left: 0px;
	top: 0px;
	position: fixed;
	height: 100%;
	width: 100%;
	overflow: hidden;
	z-index: 10000;
}

.load_img {
	left: 50%;
	top: 180px;
	position: fixed;
	height: 50px;
	overflow: hidden;
	z-index: 20000;
}
</style>
</head>
<body class="no-skin">
	<div class="load_bg" style="display: none;"></div>
	<img src="http://img.xmiles.cn/commentloading.gif" class="load_img"
		style="display: none" />
	<div class="page-content">
		<div class="page-header"
			style="margin-bottom: 0px; padding-bottom: 10px;"></div>

		<form id="queryForm" action="${ctx }/collaborate/save.action">
			<div class="page-content-area">
				<div class="row">
					<div class="col-sm-12">
						<div class="widget-box"
							style="border: 0px solid #ccc; border-top: none; border-bottom: none;">
							<div class="widget-header widget-header-blue widget-header-flat">
								<h4 class="widget-title">权限管理</h4>
								<div class="widget-toolbar">
									<a href="#" data-action="collapse"> <i
										class="ace-icon fa fa-chevron-up"></i>
									</a>
								</div>
							</div>
							<div class=" widget-body">
								<div class="widget-main">

									<div class="form-group col-xs-12 col-sm-4 col-md-3 col-lg-3">
										<label class="col-sm-4 control-label"
											style="text-align: right; font-size: 16px" for="isprize">合作方账号:</label>
										<div class="col-sm-8" style="padding-left: 0;">
											<input type="text" style="padding-left: 0px" name="username"
												id="username">
										</div>
									</div>
										<br><br><br><br><br><br>

									<div class="form-group col-xs-12 col-sm-3 col-md-3 col-lg-3">
										<label class="col-sm-4 control-label"
											style="text-align: right;font-size:16px" for="isprize">合作方名称</label>
										<div class="col-sm-8" style="padding-left: 0;">
											<select id="channel" name="channel"></select>
										</div>
									</div>
									<br><br><br><br><br><br>

									<div class="form-group col-xs-12 col-sm-4 col-md-3 col-lg-3">
										<label class="col-sm-4 control-label"
											style="text-align: right;font-size: 16px; " for="isprize">合作方系数配置</label>
										<div class="col-sm-8" style="padding-left: 0;">
											<input type="text" style="padding-left: 0px" name="ratio"
												id="ratio">&nbsp;
										</div>
									</div>
										<br><br><br><br><br><br>

									<div class="clearfix form-actions">
										<button id="btn-save" name="btn-save"
											class="btn  btn-success  no-border" type="button"
											onclick="doSave()" style="float: left">
											<i class="ace-icon fa fa-floppy-o bigger-160"></i> 保存
										</button>

									</div>

								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</form>
	</div>

	<%@ include file="/common/common-js.jsp"%>
	<script type="text/javascript" src="${ctx}/js/call_func.js"></script>
	<script type="text/javascript"
		src="${ctx}/ace/js/jquery.dataTables.min.js"></script>
	<script type="text/javascript">
	
	  function doSave() {
		var username=$('#username').val();
		var channel=$('#channel').val();
		var ratio=$('#ratio').val();
		
		if((ratio!=null&&ratio!='')&&(ratio<0)){
			alert('请输入正确的系数');
			return ;
		}
		
		if((username==null||username=='')&&(ratio<0)){
			alert('请输入合作方账号或系数配置');
			return ;
		}
		if(channel==null||channel==''){
			alert('请选择合作方渠道');
			return ;
		}
		if((username==null||username=='')&&(ratio==null||ratio=='')){
			alert("合作方账号或者系数两者不能同时为空");
			return ;
		}
		if((username!=null&&username!='')&&(channel!=null&&channel!='')&&(ratio!=null&&ratio!='')){
			alert("合作方账号和系数不能同时填写，请重新输入");
			return ;
		}
		
		$.ajax({
			   type: "POST",
			   url: ctx +"/collaborate/save.action",
			   data: "channel="+channel+"&ratio="+ratio+"&username="+username+"",
			   success: function(data){
				   alert(data.result);
			   },
			   dataType:"json"
			});
	} 
	
	
	
	$(document).ready(function() {
		//query_any();
		//initDate();
		loadChannel();
		$("#channel").combobox();
	}); 
	</script>

</body>
</html>